@namespace SwashbucklerDiary.Rcl.Components
@inherits FocusDialogComponentBase

<CustomMDialog MyValue="Visible"
                  MyValueChanged="InternalVisibleChanged"
                  ContentClass="rounded-lg"
                  MaxWidth="420"
                  DisableAutoFocus
                  OnBeforeShowContent="HandleOnBeforeShowContent"
                  OnAfterShowContent="FocusAsync">
    <MCard>
        <MCardTitle Class="font-weight-bold">
            @Title
            <MSpacer></MSpacer>
            <MButton Icon
                     OnClick="HandleOnCancel">
                <MIcon>mdi-close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText Class="pb-0">
            @if (!MultiLine)
            {
                <MTextField @bind-Value="internalText"
                            @ref="textField"
                            OnEnter="HandleOnEnter"
                            Dense
                            MinHeight="44"
                            HideDetails="@("auto")"
                            Filled
                            Rounded
                            Counter="@MaxLength"
                            maxlength="@MaxLength"
                            spellcheck="false"
                            Placeholder="@Placeholder"
                            AppendIcon="@PasswordIcon"
                            Type="@PasswordType"
                            OnAppendClick="() => showPassword = !showPassword">
                </MTextField>
            }
            else
            {
                <MTextarea @bind-Value="internalText"
                           @ref="mTextarea"
                           Class="rounded-lg"
                           HideDetails="@("auto")"
                           Filled
                           Rounded
                           NoResize
                           Rows="3"
                           Counter="@MaxLength"
                           maxlength="@MaxLength"
                           spellcheck="false"
                           Placeholder="@Placeholder">
                </MTextarea>
            }
        </MCardText>
        <MCardActions Class="pt-0">
            <MSpacer></MSpacer>
            <MButton Text
                     OnClick="HandleOnCancel">
                @(I18n.T("Share.Cancel"))
            </MButton>
            <MButton Text
                     Color="primary"
                     OnClick="HandleOnOK">
                @(OKText ?? I18n.T("Share.Save"))
            </MButton>
        </MCardActions>
    </MCard>
</CustomMDialog>